﻿@model Bids.Core.DomainObjects.Task
@{
    ViewBag.Title = "Edit";
    Layout = "~/Areas/Admin/Views/Shared/_LayoutAdmin.cshtml";
}


@section head{
    <script src="@Url.Content("~/js/kindeditor/kindeditor.js")" type="text/javascript"></script>
    <script type="text/javascript">
        $(function () {
            $(".contrAmount").click(function () {
                var _this = $(this);
                var contrId = $(this).siblings("input[name='contrId']").val();
                var amount = parseInt($(this).siblings("input[name='Amount']").val());
                if (!amount || amount <= 0) {
                    alert("酬劳金额为大于0的整数");
                    return false;
                }
                var userid = $(this).siblings("input[name='userId']").val();
                $.post("@Url.Action("ConAmount", "Task")", { "contrId": contrId, "amount": amount, "userid": userid }, function (data) {
                    if (data == "true") {
                        alert("该设计师酬劳分配成功");
                        _this.siblings("input[name='contrId']").attr("disabled", "disabled");
                        _this.siblings("input[name='Amount']").attr("disabled", "disabled");
                        _this.siblings("input[name='userId']").attr("disabled", "disabled");
                    }
                    else {
                        alert(data);
                    }
                });
            });
        });
        var editor;
        KindEditor.ready(function (K) {
            editor = K.create('#Description', {
                uploadJson: '@Url.Action("UploadImage", "Upload", new { id = "Product" })',
                fileManagerJson: '@Url.Action("UploadFile", "Upload")',
                allowFileManager: true
            });
        });
        
    </script>
}

<div class="mytopmodel">
    任务详细信息：&nbsp;&nbsp;
</div>

<form method="post" id="myform" name="myform" action="@Url.Action("Edit")">
    <div class="maindiv">
        <table cellspacing="1" id="editTable" cellpadding="3" class="mytable">
            <tr>
                <td class="text" style="width:200px;">名称：</td>
                <td class="control">@Model.Name</td>
            </tr>

            <tr>
                <td class="text">分类：</td>
                <td class="control">

                    @foreach (var item in Model.Styles)
                                {
                                    @item.Name@:&nbsp;
                                }
                </td>

            </tr>
            <tr>
                <td class="text">设计套餐：</td>
                <td class="control">
                    @Model.SetMeal.Name 
                </td>
            </tr>
            <tr>
                <td class="text">雇主用户名：</td>
                <td class="control">@Model.Employer.UserName</td>
            </tr>
            <tr>
                <td class="text">公司名称：</td>
                <td class="control">@Model.Company </td>
            </tr>
            <tr>
                <td class="text">公司口号：</td>
                <td class="control">@Model.Slogan</td>
            </tr>
            <tr>
                <td class="text">企业理念：</td>
                <td class="control">@Model.BusinessPhilosophy</td>
            </tr>
            <tr>
                <td class="text">行业：</td>
                <td class="control">@Model.Trade.Name</td>
            </tr>
            <tr>
                <td class="text">包含字符：</td>
                <td class="control">@Model.Characters</td>
            </tr>
            <tr>
                <td class="text">包含字母：</td>
                <td class="control">@Model.LettersOrNumbers</td>
            </tr>

            <tr>
                <td class="text">额外信息：</td>
                <td class="control">@Model.Extraneous</td>
            </tr>
            <tr>
                <td class="text">特征：</td>
                <td class="control">@Model.Feature</td>
            </tr>
            <tr>
                <td class="text">不喜欢的颜色：</td>
                <td class="control">
                    @Model.BadColor

                </td>
            </tr>
            <tr>
                <td class="text">喜欢的颜色：</td>
                <td class="control">
                    @Model.GoodColor
                </td>
            </tr>

            <tr>
                <td class="text">被用作：</td>
                <td class="control">@foreach (var item in Model.UsedFor)
                                {
                                    @item.Name@:&nbsp;
                                }</td>
            </tr>


            <tr>
                <td class="text">客户对象：</td>
                <td class="control">
                    @Model.Custom
                </td>
            </tr>

            <tr>
                <td class="text">是否保密：</td>
                <td class="control">
                    @(Model.KeepSecret ? "是" : "否")

                </td>
            </tr>
            <tr>
                <td class="text">任务状态：</td>
                <td class="control">
                    @Model.TaskState.ToString()
                </td>
            </tr>
            @if (Model.TaskState == Bids.Core.DomainObjects.TaskStatus.已结束)
            { 
                <tr>
                    <td class="text">结束时间：</td>
                    <td class="control">
                        @Model.FinishTime
                    </td>
                </tr> 
            }
            <tr>
                <td class="control" colspan="2">
                    <h2>支付信息</h2>
                </td>

            </tr>
            <tr>
                <td class="text">支付状态：</td>
                <td class="control">
                    @(Model.TaskPayState.ToString())
                </td>
            </tr>
            <tr>
                <td class="text">套餐费用：</td>
                <td class="control">
                    @(Model.SetMeal.Cost)元
                </td>
            </tr>
            <tr>
                <td class="text">保密费用：</td>
                <td class="control">
                    @(Model.Cost - Model.SetMeal.Cost)元
                </td>
            </tr>
            <tr>
                <td class="text">总费用：</td>
                <td class="control">
                    @(Model.Cost)元
                </td>
            </tr>
            <tr>
                <td class="text">预付费：</td>
                <td class="control">
                    @(Model.Imprest)元
                </td>
            </tr>
            @foreach (var pay in Model.TaskPays)
            {
                <tr>
                    <td class="text">支付时间：</td>
                    <td class="control">
                        @pay.PayTime
                    </td>
                </tr>
                <tr>
                    <td class="text">支付单号：</td>
                    <td class="control">
                        @pay.PayNo
                    </td>
                </tr>
                <tr>
                    <td class="text">支付帐号：</td>
                    <td class="control">
                        @pay.PayAccount
                    </td>
                </tr>
                <tr>
                    <td class="text">支付金额：</td>
                    <td class="control">
                        @pay.PayAmount
                    </td>
                </tr>
            }
            <tr>
                <td class="control" colspan="2">
                    <h2>投稿信息</h2>
                </td>

            </tr>
            <tr>
                <td class="control" colspan="2">
                    <table class="mytable" cellspacing="0" cellpadding="3" id="gvList">
                        <tr>

                            <th width="50">设计师</th>
                            <th>名称</th>
                            <th width="100">稿件状态</th>
                            <th width="150">投稿时间</th>
                            <th width="100">修改次数</th>
                            <th width="200">操作</th>
                        </tr>

                        @{
                            foreach (var item in Model.Contributions)
                            {
                                <tr class="row" onmouseover="over(event)" onmouseout="out(event)" onclick="change(event)">
                                    <td width="50" align="center">@item.Designer.UserName</td>
                                    <td align="center">@item.Title</td>
                                    <td align="center">@item.ContributionStatus.ToString()</td>
                                    <td align="center">@item.CreateTime</td>
                                    <td align="center">
                                        @(item.ContributionItems.Count - 1)
                                    </td>
                                    <td>
                                        @if(!item.HasReword)
                                        {
                                        <input type="hidden" name="contrId" value="@item.ID" />
                                        <input type="hidden" name="userId" value="@item.DesignerId" />
                                      <input type="text" name="Amount" value="0" /><input class="contrAmount" type="button" value="分配酬劳" />
                                        }
                                             </td>
                                </tr>
                            }

                            if (Model.Contributions.Count == 0)
                            {
                                <tr>
                                    <td colspan="5" style="height: 40px;">不存在数据</td>
                                </tr>
                            }
                        }
                    </table>

                </td>

            </tr>
            <tr>
                <td class="text"></td>
                <td class="control">
                    <input name="imgpath" id="imgpath" type="hidden" value="" />
                    <div class="impBtn hMargin fLeft shadow">
                        <input type="submit" value="提交" onclick="" class="save imgButton">
                    </div>
                    <div class="impBtn hMargin fLeft shadow">
                        <input type="reset" value="清空" onclick="" class="reset imgButton">
                    </div>

                    <a href="javascript:history.back(-1)">[&nbsp;返回&nbsp;] </a>

                </td>
            </tr>
        </table>


    </div>
</form>
